<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        完成一个等腰三角形打印功能
    </div>
    <div>
        封装一个函数，他的作用是，输入层数，打印等腰三角形有多少层
    </div>
    <input type="text" id="num">
    <button id="btn">提交</button>
    <div id="res">

    </div>
    <script>
        // var str = "" ;
        // var str1 = "*" ; 
        // var str2 = "-"
        // var i = 5 ; 
        // for ( var a = 1 ; a <= 9 ; a += 2  ) {
        //     for ( var b = a ; b <= 9 ; b += 2 ) {
        //         str = str + str2 ;
        //     }
        //     for ( var c = 1 ; c <= a ; c ++ ) {
        //         str = str + str1;
        //     }
        //     str = str + "</br>" ;
        // }
        // document.write(str);
        var num = document.getElementById("num");
        var btn = document.getElementById("btn");
        function isosCeles(a) {
            var str = '' ;
            for (var i = 1 ; i <= (a * 2 - 1) ; i += 2 ) {
                for ( var j = i ; j <= (a * 2 - 1) ; j += 2 ) {
                    str = str + '-' ;
                }
                for ( var k = 1 ; k <= i ; k ++ ) {
                    str = str + '*' ;
                }
                str = str + '</br>' ;
            }
            return str ;
        }
        btn.onclick = function () {
            var a = parseInt(num.value);
            document.getElementById("res").innerHTML = isosCeles(a);
        }
    </script>
</body>
</html>